home *** CD-ROM | disk | FTP | other *** search
/ PC World Komputer 2010 April / PCWorld0410.iso / pluginy Firefox / 4490 / 4490.xpi / components / ui-tb.js next >
Text File  |  2010-01-27  |  3KB  |  67 lines

  1. WebMailNotifier.prototype.openTab = function(url,name,reuse,mailDomain) {
  2.     var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
  3.              .getService(Components.interfaces.nsIWindowMediator);
  4.  
  5.   if(reuse){
  6.     var enm = wm.getEnumerator("mail:3pane");
  7.     while(enm.hasMoreElements()){
  8.       var win=enm.getNext();
  9.       var tabmail = win.document.getElementById("tabmail");  
  10.       for (var i = 0;i< tabmail.tabContainer.childNodes.length;i++){
  11.         var tab = tabmail.tabContainer.childNodes[i];
  12.         if (tab.hasAttribute("tabname")&&tab.getAttribute("tabname")==name) {
  13.           var tabbrowser=tabmail.tabInfo[i].browser;
  14.           if(this.canReuse(tabbrowser.currentURI,mailDomain)){
  15.             tabbrowser.loadURIWithFlags(url);
  16.             tabmail.tabContainer.selectedItem = tab;
  17.             win.focus();            
  18.             return;
  19.           }else{
  20.             tab.removeAttribute("tabname");
  21.           }
  22.         }
  23.       }
  24.     }
  25.   }
  26.   var win=wm.getMostRecentWindow("mail:3pane");
  27.   if(win){
  28.     var tabmail = win.document.getElementById("tabmail");
  29.     var t=tabmail.openTab("contentTab", {contentPage: url,clickHandler: "specialTabs.siteClickHandler(event,/.*/);"});
  30.     if(t){
  31.       var tab=t.tabNode;
  32.       tab.setAttribute("tabname",name);
  33.       win.focus();
  34.     }
  35.     return;
  36.   }
  37.   //not found
  38.   var win=this.getWindow().openDialog("chrome://messenger/content/", "_blank",  
  39.                       "chrome,dialog=no,all", null,  
  40.                       { tabType: "contentTab",  
  41.                         tabParams: {contentPage: url,clickHandler: "specialTabs.siteClickHandler(event,/.*/);"} }); 
  42.   win.focus();
  43. }
  44. WebMailNotifier.prototype.openNewWindow = function() {
  45.   this.getWindow(true);
  46. }
  47. WebMailNotifier.prototype.openWindow = function(url,name,reuse,mailDomain) {
  48.   if(!this.messenger){
  49.   this.messenger = Components.classes["@mozilla.org/messenger;1"]
  50.                         .createInstance(Components.interfaces.nsIMessenger);
  51.   }
  52.   this.messenger.launchExternalURL(url);
  53. }
  54. WebMailNotifier.prototype.getWindow = function(notChrome) {
  55.   var wm = Components.classes['@mozilla.org/appshell/window-mediator;1']
  56.                       .getService(Components.interfaces.nsIWindowMediator);
  57.   var win = wm.getMostRecentWindow("mail:3pane");
  58.   if(win==null){
  59.     win=Components.classes["@mozilla.org/appshell/appShellService;1"]
  60.                     .getService(Components.interfaces.nsIAppShellService).hiddenDOMWindow;
  61.     if(notChrome){
  62.       win=win.openDialog("chrome://messenger/content/", "_blank",  
  63.                       "chrome,dialog=no,all", null, null);     
  64.     }      
  65.   }
  66.   return  win;
  67. }